home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 July
/
EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso
/
lightwave
/
arexx_macros
/
lwscenemacros
/
chkscene.rexx
next >
Wrap
OS/2 REXX Batch file
|
1994-09-05
|
7KB
|
227 lines
/*
ChkScene.rexx
Copyright (C) 1994 Earl C. Terwilliger
Phone (606)-723-5718
Internet: AISTERWI@ACS.EKU.EDU
Conmpuserve: 70575,1330
Non-Commercial USE granted to ALL !!!
One of the problems with giving a LW scene
to someone else is that you have to give
the other files that are referenced in
the scene file and referenced in the
objects files (such as texture maps and
reflection maps, etc.) too.
You can easily forget to include a file when
copying your scene, object and image files
files to diskette.
ChkScene.rexx checks a Lightwave Scene file
and objects files it references to make sure
that the file names referenced in them do
indeed exist. If a file is not found that
is referenced, an error message and the
error reason is displayed. Some files which
are reported as not found are ok since they
may refer to files created via the SAVE RGB
or Save Anim LW scene commands. Also some
files referencing the supplied LW sample
objects may not be found if no specific
drive:directory reference is given, however
they will load OK in LW layout even though
ChkScene reports the file is not found.
Syntax: rx ChkScene [drive:directory/]LW-Scene-File
NOTE: The ChkScene.rexx script checks a
single LW scene file, whereas another script
called ChkScenes.rexx checks a whole drive:[directory]
structure for all LW scene files it finds.
*/
/* TRACE(RESULTS) */
OPTIONS RESULTS
parse arg file
if arg() = 0 then call syntax()
if ~exists(file) then call syntax()
if (index(file,':') ~= 0) then do
temp = translate(file," ","/:"," ")
tempwords = words(temp)
name = word(temp,tempwords)
source = left(file,length(file)-length(name))
end
else source = pragma('D')
if (right(source,1) ~= ':') then do
if (right(source,1) ~= '/') then source = source||'/'
end
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then
say "Added rexxsupport.library."
else do
say "Error: addlib() of rexxsupport.library failed."
exit 10
end
end
open('infile',file,'R')
instring=readln('infile')
if (pos('LWSC',instring) ~= 1) then do
close('infile')
say file' is not a LW scene file!'
exit(10)
end
say
say '[Input Scene File Name]'file
do while eof('infile')=0
instring = readln('infile')
lwcmd = word(instring,1)
c = index(lwcmd,'Load')
if (index(instring,':') ~= 0) then do
if (index(instring,'/') ~= 0) then c = c + 1
end
if (c > 0) then do
filename = word(instring,2)
if (index(instring,':') = 0) then do
if (left(filename,1) ~= '/') then filename = source||filename
else filename = source||strip(filename,'L','/')
end
temp = upper(translate(filename," ","/:"," "))
c = showlist('A',word(temp,1))
c = c + showlist('H',word(temp,1))
if (c = 0) then do
say instring
call errmsg('Volume Not Mounted - ERROR')
end
else if (~exists(filename)) then do
temp = translate(filename," ","/:"," ")
tempwords = words(temp)
name = word(temp,tempwords)
objname = source||'objects/'||name
if (exists(objname)) then do
say filename 'exists as' objname
filename = objname
if (index(lwcmd,"LoadObject") ~= 0) then call readlwob()
end
else do
say instring
call errmsg('File Not Found - ERROR')
end
end
else do
say instring ' [OK]'
if (index(lwcmd,"LoadObject") ~= 0) then call readlwob()
end
end
end
close('infile')
say '<- Check Scene completed ->'
exit 0
syntax:
say
say 'Syntax: rx ChkScene [drive:directory/]LW-Scene-File'
say
exit 10
readlwob: PROCEDURE EXPOSE source filename
OPTIONS RESULTS
open('lwobfile',filename,'R')
objstring = readch('lwobfile',12)
type = substr(objstring,9,4)
if (type ~= "LWOB") then do
close('lwobfile')
say filename
call errmsg('This is not a LW Object file! - ERROR')
return 10
end
form = substr(objstring,1,4)
length = c2d(substr(objstring,5,4),4)
length = length + 8
say 'Reading from' filename
/* say 'Object file length is' length 'bytes' */
open('lwobout',destname,'W')
do while eof('lwobfile')=0
objstring=readch('lwobfile',8)
if (eof('lwobfile') = 1) then break
chunk = substr(objstring,1,4)
length = c2d(substr(objstring,5,4),4)
/* say 'Chunk Type is' chunk 'with a length of' length 'bytes' */
if (chunk ~= "SURF") then seek('lwobfile',length,'C')
else do
objstring = readch('lwobfile',length)
surfacepos = pos('00'x,objstring,1)
surface = substr(objstring,1,(surfacepos-1))
surfacepos = surfacepos + (surfacepos // 2) + 1
say 'Surface Name:' surface
do while (surfacepos < length)
subchunk = substr(objstring,surfacepos,4)
/* say 'Subchunk ' subchunk */
surfacepos = surfacepos + 4
len = c2d(substr(objstring,surfacepos,2),4)
surfacepos = surfacepos + 2
image = ""
if (subchunk = "TIMG") then do
image = strip(substr(objstring,surfacepos,len),'T','00'x)
say 'Texture Image ->' image
end
if (subchunk = 'RIMG') then do
image = strip(substr(objstring,surfacepos,len),'T','00'x)
say 'Reflection Image ->' image
end
if (image = "(none)") then image = ""
if (image ~= "") then do
if (index(image,':') = 0) then do
if (left(image,1) ~= '/') then fullimage = source||image
else fullimage = source||strip(image,'L','/')
end
else fullimage = image
temp = translate(fullimage," ","/:"," ")
tempwords = words(temp)
name = word(temp,tempwords)
directory = left(fullimage,length(fullimage)-length(name))
if (~exists(directory)) then do
if (exists(source||"images")) then fullimage = source||'images/'||name
end
if (index(image,"(sequence)",1) = 0) then do
if (~exists(fullimage)) then do
say fullimage
call errmsg('File Not Found - ERROR')
end
end
end
surfacepos = surfacepos + len
end
end
end
close('lwobfile')
return 0
errmsg: procedure
parse arg msg
len = length(msg) - 1
errmsg = '|___________________________________________________________________________'
errmsg = overlay(msg,errmsg,length(errmsg)-len,len+1)
say errmsg
return 0